import java.util.HashMap;
import java.util.HashSet;
import java.util.StringTokenizer;


class P11518_39643 {

	static String readLn() {
		String newLine = System.getProperty("line.separator");
		StringBuilder buffer = new StringBuilder();
		int car = -1;
		try {
			car = System.in.read();
			while ((car > 0) && (car != newLine.charAt(0))) {
				buffer.append((char) car);
				car = System.in.read();
			}
			if (car == newLine.charAt(0))
				System.in.skip(newLine.length() - 1);
		} catch (java.io.IOException e) {
			return (null);
		}
		if ((car < 0) && (buffer.length() == 0))
			return (null);
		return (buffer.toString());
	}
	
	public static void main(String[] args) {
		int cases = Integer.parseInt(readLn());
		
		for (int k = 0; k < cases; k++) {
			StringTokenizer st = new StringTokenizer(readLn());
			int n = Integer.parseInt(st.nextToken());
			int m = Integer.parseInt(st.nextToken());
			int l = Integer.parseInt(st.nextToken());
		
			HashMap<Integer, HashSet<Integer>> graph = new HashMap<Integer, HashSet<Integer>>();
			
			for (int i = 1; i <= n; i++) {
				graph.put(i, new HashSet<Integer>());
			}
			
			for (int i = 0; i < m; i++) {
				st = new StringTokenizer(readLn());
				
				int x = Integer.parseInt(st.nextToken());
				int y = Integer.parseInt(st.nextToken());
				
				graph.get(x).add(y);
				
			}
			
			HashSet<Integer> knocked = new HashSet<Integer>();
			
			for (int i = 0; i < l; i++) {
				int z = Integer.parseInt(readLn());
				
				putKnocked(z, graph, knocked);
				
			}
			
			System.out.println(knocked.size());
			
		}
		
	}

	private static void putKnocked(int z,
			HashMap<Integer, HashSet<Integer>> graph, HashSet<Integer> knocked) {
		
		if (knocked.contains(z))
			return;
		
		knocked.add(z);
		
		for (int ko : graph.get(z)) {
			putKnocked(ko, graph, knocked);
		}
		
	}
	
}
